/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.company.workflow.loader;

/**
 * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a>
 * @version $Revision: 1.2 $
 */
public class PermissionDescriptor extends AbstractDescriptor
{
	// ~ Instance fields
	// ////////////////////////////////////////////////////////

	protected RestrictionDescriptor restriction;

	protected String name;

	// ~ Constructors
	// ///////////////////////////////////////////////////////////

	public PermissionDescriptor()
	{
	}

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	public void setName(String name)
	{
		this.name = name;
	}

	public String getName()
	{
		return name;
	}

	public void setRestriction(RestrictionDescriptor restriction)
	{
		this.restriction = restriction;
	}

	public RestrictionDescriptor getRestriction()
	{
		return restriction;
	}

	public String getXML()
	{
		StringBuffer buf = new StringBuffer();
		buf.append("<permission ");

		if (hasId())
		{
			buf.append("id=\"" + getId() + "\" ");
		}

		buf.append("name=\"" + name + "\">");
		buf.append(restriction.getXML());

		buf.append("</permission>");
		return buf.toString();
	}

}
